/**
 * Created by jyh on 02/07/2017.
 */
import Vue from 'vue'

Vue.filter('substring', (value, start, end) => {
  if (typeof value === 'string') {
    if (value.length > end - start) {
      return value.substring(start, end) + '...'
    } else {
      return value.substring(start, end)
    }
  } else {
    return value
  }
})

Vue.filter('newsTitleSubstring', (value, start, end) => {
  if (typeof value === 'string') {
    if (value.length > end - start) {
      return value.substring(start, end)
    } else {
      return value.substring(start, end)
    }
  } else {
    return value
  }
})

Vue.filter('formatDate', (value, format) => {
  return moment(value).format(format)
})

Vue.filter('saleStatus', (value) => {
  var map = {
    'kSALING': '商业',
    'kSALE_WATING': '待售',
    'kSALE_STOP': '停售'
  }
  return map[value]
})

Vue.filter('houseType', (value) => {
  var map = {
    'kBUSINESS': '商业',
    'kRESIDENTIAL': '住宅',
    'kVILLE': '别墅',
    'kAPARTMENT': '公寓',
    'kOFFICE_BUILDING': '写字楼'
  }
  return map[value]
})
Vue.filter('decorationStatus', (value) => {
  var map = {
    'kEXQUISITE': '精装修',
    'kBLANK': '毛坯',
    'kFANCY': '豪装',
    'kSIMPLE': '简装'
  }
  return map[value]
})

Vue.filter('huXingType', (value) => {
  var map = {
    'kA_SET_OF_ONE': '一室一厅',
    'kA_SET_OF_TWO': '两室一厅',
    'kA_SET_OF_THREE': '三室一厅',
    'kA_SET_OF_FOUR': '四室一厅',
    'kA_SET_OF_FIVE': '五室一厅',
    'kA_SET_OF_SIX': '六室一厅',
    'kOther': '其它',
  }
  return map[value]
})

Vue.filter('phone', (value) => {
  if (typeof value !== 'string') return value
  return value.replace(/(.{4})/g, '$1-')
})

Vue.filter('homeCoverPic',(path) => {
   return path+'?imageMogr2/auto-orient/thumbnail/!274x220r/gravity/Center/crop/274x220/blur/1x0/quality/75|watermark/2/text/5oiQ6YO95ZCJ5YWD5rGH/font/5qW35L2T/fontsize/200/fill/I0Y0RTFFMQ==/dissolve/100/gravity/NorthWest/dx/10/dy/10|imageslim';
});

Vue.filter('houseDetailsBigPic',(path) => {
   return path+'?imageMogr2/auto-orient/thumbnail/!1190x360r/gravity/Center/crop/1190x360/blur/1x0/quality/75|watermark/2/text/5oiQ6YO95ZCJ5YWD5rGH/font/5qW35L2T/fontsize/240/fill/I0UyRENEQw==/dissolve/100/gravity/SouthWest/dx/10/dy/10|imageslim';
});

Vue.filter('newsCoverPic',(path) => {
   return path+'?imageMogr2/auto-orient/thumbnail/!270x200r/gravity/Center/crop/270x180/blur/1x0/quality/75|watermark/2/text/5oiQ6YO95ZCJ5YWD5rGH/font/5qW35L2T/fontsize/240/fill/IzAwMDAwMA==/dissolve/100/gravity/SouthWest/dx/10/dy/10|imageslim';
});

Vue.filter('picDetails',(path) => {
   return path+'?imageMogr2/thumbnail/!438x288r/gravity/SouthWest/crop/400x280/blur/1x0/quality/75|watermark/2/text/5oiQ6YO95ZCJ5YWD5rGH/font/5qW35L2T/fontsize/600/fill/I0UyRENEQw==/dissolve/100/gravity/SouthWest/dx/10/dy/10|imageslim';
});
/*
  新房中的推荐房源
*/
Vue.filter('newHouseRecommend',(path) => {
   return path+'?imageMogr2/auto-orient/thumbnail/296x220/gravity/Center/crop/286x220/blur/1x0/quality/75|watermark/2/text/5oiQ6YO95ZCJ5YWD5rGH/font/5qW35L2T/fontsize/240/fill/I0YxRTVFNQ==/dissolve/100/gravity/NorthWest/dx/10/dy/10|imageslim';
});
/*
  二手房中的推荐房源
*/
Vue.filter('twoHouseRecommend',(path) => {
   return path+'?imageMogr2/auto-orient/thumbnail/!325x220r/gravity/Center/crop/325x220/blur/1x0/quality/75|watermark/2/text/5oiQ6YO95ZCJ5YWD5rGH/font/5qW35L2T/fontsize/240/fill/I0Y4RjBGMA==/dissolve/100/gravity/NorthWest/dx/10/dy/10|imageslim';
});

Vue.filter('twoHouseListCoverPic',(path) => {
   return path+'?imageMogr2/auto-orient/thumbnail/!260x190r/gravity/Center/crop/260x190/blur/1x0/quality/75|watermark/2/text/5oiQ6YO95ZCJ5YWD5rGH/font/5qW35L2T/fontsize/240/fill/I0Y5RjNGMw==/dissolve/100/gravity/NorthWest/dx/10/dy/10|imageslim';
});
Vue.filter('newHouseList',(path) => {
   return path+'?imageMogr2/auto-orient/thumbnail/!370x245r/gravity/Center/crop/370x245/blur/1x0/quality/75|watermark/2/text/5oiQ6YO95ZCJ5YWD5rGH/font/5qW35L2T/fontsize/240/fill/I0ZBRjRGNA==/dissolve/100/gravity/NorthWest/dx/10/dy/10|imageslim';
});

